from django.db import models

class City(models.Model):
    """
    城市
    """
    city_name = models.CharField(default="", max_length=20, verbose_name="名称")
    city_url = models.CharField(default="", max_length=200, verbose_name="连接地址", unique=True)

    class Meta:
        verbose_name = '城市'
        verbose_name_plural = verbose_name


class CityPage(models.Model):
    """
    城市下所有分页连接
    """
    page_url = models.CharField(default="", max_length=200, verbose_name="连接地址", unique=True)
    city = models.ForeignKey(City, blank=True, null=True, on_delete=models.CASCADE)
    pici = models.IntegerField(verbose_name="抓取批次", default=0)

    class Meta:
        verbose_name = '城市分页'
        verbose_name_plural = verbose_name


DOING_STATE = (
    (1, "草稿"),
    (2, "成功"),
    (3, "异常"),
)
class DanceCompany(models.Model):
    """
    所有培训班详情
    """
    company_url = models.CharField(default="", max_length=200, verbose_name="连接地址", unique=True)
    title = models.CharField(default="", max_length=200, verbose_name="标题")
    lianxiren = models.CharField(default="", max_length=200, verbose_name="联系人", blank=True, null=True)
    phone = models.CharField(default="", max_length=200, verbose_name="联系电话", blank=True, null=True)
    renzheng = models.CharField(default="", max_length=200, verbose_name="认证", blank=True, null=True)
    desc = models.TextField(default="", verbose_name="详情描述", blank=True, null=True)
    city_page = models.ForeignKey(CityPage, blank=True, null=True, on_delete=models.CASCADE)
    state = models.IntegerField(choices=DOING_STATE, verbose_name="获取状态", default=1)

    class Meta:
        verbose_name = '培训班详情'
        verbose_name_plural = verbose_name
